//
//  GWReportStatuseFrame.m
//  新浪微博
//
//  Created by qianfeng on 16/2/18.
//  Copyright (c) 2016年 高炜. All rights reserved.
//

#import "GWReportStatuseFrame.h"
#import "GWStatuseModel.h"
#import "GWStatusePhotosView.h"
@implementation GWReportStatuseFrame
-(void)setStatuse:(GWStatuseModel *)statuse
{
    _statuse =statuse;
    /**昵称*/
//    CGFloat nameX =HomeStatuseCellInset;
//    CGFloat nameY =HomeStatuseCellInset;
//    NSString *name =[NSString stringWithFormat:@"@%@",statuse.user.name];
//    CGSize nameSize =[name boundingRectWithSize:CGSizeMake(300, 20) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:OriginalStatuseNameFont} context:nil].size;
//    self.nameLabelF =(CGRect){{nameX,nameY},nameSize};
    
    /**正文*/
    CGFloat textX =HomeStatuseCellInset;
    CGFloat textY =HomeStatuseCellInset;
    CGSize textSize = [statuse.attributedText boundingRectWithSize:CGSizeMake(GWScreenW-2*textX, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin context:nil].size;
//    CGSize textSize =[statuse.text boundingRectWithSize:CGSizeMake(GWScreenW-2*textX, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:OriginalStatuseTextFont} context:nil].size;
    self.textLabelF =(CGRect){{textX,textY},textSize};
    
    CGFloat h =0;
    if (statuse.pic_urls.count) {
        CGFloat photoX =HomeStatuseCellInset;
        CGFloat photoY =CGRectGetMaxY(self.textLabelF)+HomeStatuseCellInset;
        CGSize photosSize =[GWStatusePhotosView photosViewSizeWithPhotoCount:(int)statuse.pic_urls.count];
        self.photosViewF =(CGRect){{photoX,photoY},photosSize};
        h=CGRectGetMaxY(self.photosViewF)+HomeStatuseCellInset;
    }
    else
    {
        h=CGRectGetMaxY(self.textLabelF)+HomeStatuseCellInset;
    }
    if (statuse.isDetail) {
        CGFloat toolBarW =200;
        CGFloat toolBarX =GWScreenW -toolBarW;
        CGFloat toolBarH =20;
        CGFloat toolBarY =h;
        self.toolBarF =CGRectMake(toolBarX, toolBarY, toolBarW, toolBarH);
        h=CGRectGetMaxY(self.toolBarF)+HomeStatuseCellInset;
    }
    
    self.frame =CGRectMake(0, 0, GWScreenW, h);
}
@end
